package com.example.service.Impl;

import com.example.mapper.CourseMapper;
import com.example.pojo.Course;
import com.example.pojo.CourseLearnUnit;
import com.example.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;

    //课程创建
    @Override
    public void createCourse(Course course) {
        course.setCreateTime(LocalDate.now());
        courseMapper.createCourse(course);
    }
    //课程查询
    @Override
    public Course queryByName(String courseName) {
        Course course = courseMapper.queryByName(courseName);
        return course;
    }
    //学习单元创建
    @Override
    public void createUnit(CourseLearnUnit courseLearnUnit) {
        courseMapper.createLearnUnit(courseLearnUnit);
    }

    //学习单元查询
    @Override
    public CourseLearnUnit queryByTitle(String unitTitle) {
        CourseLearnUnit learnUnit = courseMapper.queryByTitle(unitTitle);
        return learnUnit;
    }
}
